package com.knight.spring.aop;

import com.knight.spring.bean.Student;
import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import java.util.ArrayList;
import java.util.List;

public class SpringAOPClient {
    public static void main(String[] args) {

        Resource resource = new ClassPathResource("applicationContext-apo.xml");

        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        BeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);

        int num = beanDefinitionReader.loadBeanDefinitions(resource);
        System.out.println(num);

        MyService myAop = beanFactory.getBean("myAop", MyService.class);
        myAop.myMethod();
    }
}
